package itypes

import (
	"server/game/model"
	"server/share/config"

	"github.com/hwcer/logger"
	"github.com/hwcer/updater"
)

var Chapter = NewIType(config.ITypeChapter)

func init() {
	Chapter.SetCreator(chapterCreator)
	im := &model.Chapter{}
	if err := updater.Register(updater.ParserTypeCollection, updater.RAMTypeNone, im, Chapter); err != nil {
		logger.Panic(err)
	}
}

func chapterCreator(u *updater.Updater, iid int32, val int64) (any, error) {
	i := &model.Chapter{IID: iid, Uid: u.Uid()}
	i.OID = Chapter.ObjectId(u, iid)
	i.Stage = map[int32]*model.Stage{}
	return i, nil
}
